y <- iris[, 1]
x <- as.matrix(iris[, 2:4])
x <- x/ sqrt( rowSums(x^2) ) ## Euclidean response
a <- knn.reg(x, y, x, k = 5, res = "eucl", estim = "arithmetic")
y <- iris[, 2:4]
y <- y / sqrt( rowSums(y^2) ) ## Spherical response
x <- iris[, 1]
a <- knn.reg(x, y, x, k = 5, res = "spher", estim = "arithmetic")
Run the code above in your browser using DataLab